﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShengChengJQTS.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.ShouFeiGL.ShengChengJQTS" Theme="Default" %>

 <%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../../JS/jquery.js"></script>
    <script src="../../../../JS/AddEditCancel.js"></script>
    <script type="text/javascript">
        
      

       
        //打开子窗体
        function openWindow(type) {
            //if (type ==1) {//旧欠汇总
            //    openCenter("/Pages/YongShui/5.ShouFeiGL/JiuQianTSHZ.aspx?", "600px", "670px");
            //}
            //else if (type == 2) {//增加托收明细
            //    //此时为进账单未到账,进一步判断银行接口是否上传
            //    if (hdCollection.Get('sczt') == "1")
            //    {
            //        alert('已上传,不能增加或删除！请再生成一个新的进账单。');
            //        return;
            //    }
            //    var sfbh = getKeyToArr()[0];
            //    openCenter("/Pages/YongShui/5.ShouFeiGL/JiuQianTSMX_ZJ.aspx?guanlikh=" + cmbconGuanlik.GetValue() + "&sfbh=" + sfbh, "900px", "450px");
            //}
            //else if (type == 3) {//生成新的进账单
            //    //判断是否可以生成
            //    ASPxCallback1.PerformCallback("createnew");                
            //}
        }
        
       

        function grid1focus()
        {
            var dzbz = getKeyToArr()[1];
            if (dzbz != "1") {
                btnCreateNew.SetEnabled(true);
                //btnOpenAddDetail.SetEnabled(true);
            }
            else {
                btnCreateNew.SetEnabled(false);
                //btnOpenAddDetail.SetEnabled(false);
            }
            gvList2.PerformCallback();
        }
        function grid1endcallback() {
                grid1focus();   
        }

        function grid2endcallback()
        {
            var dzbz = getKeyToArr()[1];
            if (dzbz == "1") {
                $(".aDel").hide();
            }
            else {
                $(".aDel").show();
            }
        }
        //删除托收凭证
        function delmx()
        {
            //上传标志
            var scbz = "1";//getKeyToArr()[2];
            //var scbz = hdCollection.Get("scbz");
            if (scbz == "1") {
                alert('已上传,不能增加或删除！请再生成一个新的进账单。');
                return false;
            }
            if (confirm('你确认取消当前的托收凭证吗？')) {
                ASPxCallback1.PerformCallback("delmx");
                LoadPanel.Show();
            }
        }

        function getKeyToArr()
        {
            return "";//gvList1.GetRowKey(gvList1.GetFocusedRowIndex()).split(',');
        }
        
    </script>
    <script type="text/javascript">

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            var specialIdentity = arr[2];
            var msg = arr[3].split('-');
            LoadPanel.Hide();
            if (msg[0] == 'True') {
                alert(msg[1]);
            }
            //debugger;
            hdCollection.Set("type", type);
            if (state == 'True') {
                if (type == "createnew") {
                    openCenter("/Pages/YongShui/5.ShouFeiGL/JiuQianTSMX_ZJ.aspx?guanlikh=" + cmbconGuanlik.GetValue(), "900px", "450px");
                }
                else if (type == "delmx") {
                    btnRunServer.onClick();
                }
                else if (type == "search") {
                    gvList2.SetFocusedRowIndex(arr[4]);
                    gvList2.MakeRowVisible(arr[4]);
                }
            }
            else {
            }
        }

        
</script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            生成旧欠托收
        </div>
        <asp:UpdatePanel ID="updatePanel1" runat="server">
            <ContentTemplate>
                <dx:ASPxHiddenField ID="ASPxHiddenField1" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
                <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
                <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="LoadPanel" runat="server"></dx:ASPxLoadingPanel>
                <dx:ASPxButton ID="btnRunServer" ClientInstanceName="btnRunServer"  ClientVisible="false" runat="server" Text="ASPxButton"></dx:ASPxButton>

                <div class="top" style="width: 98%; margin: auto;">
                    <fieldset style="border: 1px solid  #d0e4fe; width: 98%; margin: auto;">
                        <legend style="font-weight: bold">进账单列表</legend>
                        <table>
                            <tr>
                                <td></td>
                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <dx:ASPxButton ID="btnCreateNew" ClientInstanceName="btnCreateNew" runat="server" Text="生成新的进账单" AutoPostBack="false" UseSubmitBehavior="false">
                                    <ClientSideEvents Click="function(s,e){openWindow(3);}" />
                                </dx:ASPxButton>
                                </td>

                            </tr>
                        </table>
                        <dx:ASPxGridView ID="gvList1" ClientInstanceName="gvList1" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="100%" EnableCallBacks="true" OnCustomCallback="gvList1_CustomCallback" >
                            <Columns>
                                <dx:GridViewDataTextColumn FieldName="S_BIANHAO" Caption="进帐单编号" Width="10%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="N_ZONGJINE" Caption="总金额" Width="15%" PropertiesTextEdit-DisplayFormatString="0.00">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="I_ZONGSHU" Caption="总笔数" Width="10%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="D_RIQI" Caption="进账单生成日期" Width="20%" PropertiesTextEdit-DisplayFormatString="yyyy-MM-dd">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_LEIXINGMC" Caption="送盘类型" Width="30%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="I_YM" Caption="托收年月" Width="10%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="5%">
                                    <DataItemTemplate>
                                        <a class="aDel" runat="server" id="aDel1" href="#" onclick="delmx();">删除</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <Settings VerticalScrollableHeight="100" VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" />
                            <SettingsBehavior ProcessFocusedRowChangedOnServer="false" SortMode="Custom" />
                            <%--<ClientSideEvents FocusedRowChanged="function(s,e){grid1focus();}" EndCallback="function(s,e){grid1focus();}" />--%>
                        </dx:ASPxGridView>
                    </fieldset>
                </div>
                <div style="width: 98%; text-align: center; margin: auto;">
                    <fieldset style="border: 1px solid  #d0e4fe; width: 98%; margin: auto;">
                        <legend style="font-weight: bold">托收明细列表</legend>
                        <div style="height: 1px"></div>
                        <table>
                            <tr>
                                <td></td>
                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <dx:ASPxButton ID="btnCreateNew2" ClientInstanceName="btnCreateNew2" runat="server" Text="生成旧欠托收明细" AutoPostBack="false" UseSubmitBehavior="false">
                                    <ClientSideEvents />
                                </dx:ASPxButton>
                                </td>

                            </tr>
                        </table>
                        <div style="height: 1px"></div>
                        <dx:ASPxGridView ID="gvList2" ClientInstanceName="gvList2" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="100%" OnCustomCallback="gvList2_CustomCallback">
                            <Columns>
                                <dx:GridViewDataTextColumn FieldName="S_TUOSHOUBH" Caption="托收凭证" Width="80px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_YONGHUH" Caption="用户号" Width="80px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_YONGHUM" Caption="用户名" Width="250px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="YM" Caption="水量年月" Width="60px" CellStyle-HorizontalAlign="Center">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="SHUILIANG" Caption="水量" Width="60px" CellStyle-HorizontalAlign="Center">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="TUOSHOUJE" Caption="金额" Width="80px" PropertiesTextEdit-DisplayFormatString="0.00">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_YINHANGHM" Caption="开户户名" Width="250px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_YINHANGZH" Caption="银行账号" Width="150px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_KAIHUYH" Caption="开户银行" Width="150px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="45px">
                                    <DataItemTemplate>
                                        <a class="aDel" runat="server" id="aDel2" href="#" onclick="delmx();">删除</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <Settings VerticalScrollableHeight="260" VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" />
                            <%--<ClientSideEvents EndCallback="function(s,e){grid2endcallback();}" />--%>
                        </dx:ASPxGridView>
                    </fieldset>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html> 
